package com.teamclub.app.scontrollers.systemmanager

import javax.validation.Valid
import com.teamclub.app.sforms.AppSubjectUserForm
import com.teamclub.app.sservices.systemmanager.AppSubjectUserService
import com.teamclub.util.libs.Eithers
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.{PostMapping, RequestBody, RequestMapping, RestController}

/**
  * Created by ilkkzm on 17-7-27.
  */

@RestController("com.teamclub.app.scontrollers.systemmanager.AppSubjectUserController")
@RequestMapping(Array("/app/systemmanager"))
class AppSubjectUserController {
  @Autowired
  var appSubjectUserService: AppSubjectUserService = _

  @PostMapping(Array("userlist"))
  def list(@RequestBody form:AppSubjectUserForm) =  {
    Eithers.toJson(appSubjectUserService.list(form))
  }

  @PostMapping(Array("useradd"))
  def add(@RequestBody @Valid form: AppSubjectUserForm) = {
    Eithers.toJson(appSubjectUserService.add(form))
  }
  @PostMapping(Array("userdel"))
  def del(@RequestBody form: AppSubjectUserForm) = {
    Eithers.toJson(appSubjectUserService.del(form))
  }
  @PostMapping(Array("judgeIsRegister"))
  def judgeIsRegister(@RequestBody form: AppSubjectUserForm) = {
    Eithers.toJson(appSubjectUserService.judgeIsRegister(form))
  }
}
